<!DOCTYPE html>

<html>
<head>
	<title>AIL-Framework</title>
	<link rel="icon" href="{{ url_for('static', filename='image/ail-icon.png')}}">
	<!-- Core CSS -->
	<link href="{{ url_for('static', filename='css/bootstrap4.min.css') }}" rel="stylesheet">
	<link href="{{ url_for('static', filename='css/font-awesome.min.css') }}" rel="stylesheet">
	<link href="{{ url_for('static', filename='css/dataTables.bootstrap.min.css') }}" rel="stylesheet">

	<!-- JS -->
	<script src="{{ url_for('static', filename='js/jquery.js')}}"></script>
  <script src="{{ url_for('static', filename='js/bootstrap4.min.js')}}"></script>
  <script src="{{ url_for('static', filename='js/jquery.dataTables.min.js')}}"></script>
	<script src="{{ url_for('static', filename='js/dataTables.bootstrap.min.js')}}"></script>

</head>

<body>

	{% include 'nav_bar.html' %}

	<div class="container-fluid">
		<div class="row">

			{% include 'settings/menu_sidebar.html' %}

			<div class="col-12 col-lg-10" id="core_content">

				<div class="card">
					<div class="card-header bg-dark text-white">
						<h4 class="card-title">SYNC Queue: {{queue_metadata['uuid']}}</h4>
					</div>
					<div class="card-body">
						<table class="table table-borderless">
							<tbody>
								<tr>
									<td class="text-right"><b>Name</b></td>
									<td>
										{{queue_metadata['name']}}
									</td>
								</tr>
								<tr>
									<td class="text-right"><b>Tags Filter</b></td>
									<td>
										<div>
											{% for tag in queue_metadata['tags'] %}
												<span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }} pull-left">{{ tag }}</span>
											{% endfor %}
										</div>
									</td>
								</tr>
								<tr>
									<td class="text-right"><b>Description</b></td>
									<td>
										{{queue_metadata['description']}}
									</td>
								</tr>
								<tr>
									<td class="text-right"><b>Max Size</b></td>
									<td>
										{{queue_metadata['max_size']}}
									</td>
								</tr>
							</tbody>
						</table>

						<div class="my-4">
							<a href="{{ url_for('ail_2_ail_sync.sync_queue_delete') }}?uuid={{queue_metadata['uuid']}}">
								<button type="button" class="btn btn-danger">
									<i class="fas fa-trash-alt"></i> <b>Delete Sync Queue</b>
									</button>
							</a>
							<a href="{{ url_for('ail_2_ail_sync.sync_queue_edit') }}?uuid={{queue_metadata['uuid']}}">
								<button type="button" class="btn btn-info">
									<i class="fas fa-pencil-alt"></i> <b>Edit</b>
								</button>
							</a>
						</div>

						<div class="card">
							<div class="card-header bg-secondary text-white">
								<h5 class="card-title"><b>AIL Server:</b></h5>
							</div>
							<div class="card-body">

								<a href="{{ url_for('ail_2_ail_sync.ail_server_add') }}">
									<button type="button" class="btn btn-primary my-4">
										<i class="fas fa-plus"></i> <b>Create AIL Server</b>
									</button>
								</a>

								<table id="table_sync_queues" class="table table-striped border-primary">
				          <thead class="bg-dark text-white">
				            <tr>
												<th>uuid</th>
				                <th>url</th>
				                <th>description</th>
				                <th>pull</th>
												<th>push</th>
												<th></th>
				            </tr>
				          </thead>
				          <tbody style="font-size: 15px;">
				            {% for dict_server in queue_metadata['ail_servers'] %}
				              <tr class="border-color: blue;">
												<td>{{ dict_server['uuid']}}</td>
												<td>{{ dict_server['url']}}</td>
				                <td>{{ dict_server['description']}}</td>
												<td>{{ dict_server['pull']}}</td>
												<td>{{ dict_server['push']}}</td>
												<td class="text-right">
													<a href="{{ url_for('ail_2_ail_sync.ail_server_sync_queues_unregister') }}?ail_uuid={{ dict_server['uuid'] }}&queue_uuid={{ queue_metadata['uuid'] }}">
														<button type="button" class="btn btn-danger"><i class="fas fa-trash-alt"></i></button>
													</a>
												</td>
				              </tr>
				            {% endfor %}
				          </tbody>
				        </table>


					</div>


				</div>
			</div>


		</div>

	</div>

</body>

<script>
$(document).ready(function(){
	$('#nav_sync').removeClass("text-muted");

  $('#table_sync_queues').DataTable({
        "aLengthMenu": [[5, 10, 15, -1], [5, 10, 15, "All"]],
        "iDisplayLength": 10,
        "order": [[ 0, "asc" ]]
  });

});


function toggle_sidebar(){
	if($('#nav_menu').is(':visible')){
		$('#nav_menu').hide();
		$('#side_menu').removeClass('border-right')
		$('#side_menu').removeClass('col-lg-2')
		$('#core_content').removeClass('col-lg-10')
	}else{
		$('#nav_menu').show();
		$('#side_menu').addClass('border-right')
		$('#side_menu').addClass('col-lg-2')
		$('#core_content').addClass('col-lg-10')
	}
}

</script>
